package com.iplay.listener;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;

import com.iplay.dao.user.userInfo.UserBasicInfoDAO;
import com.iplay.service.storage.StorageService;

@Component
public class ApplicationReadyEventListener implements ApplicationListener<ApplicationReadyEvent>, Ordered {
	@Autowired
	private StorageService storageService;
	
    @Override
    public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) {
    	storageService.store(
				ApplicationReadyEventListener.class.getResourceAsStream("/img/" + UserBasicInfoDAO.DEFAULT_AVATAR),
				UserBasicInfoDAO.DEFAULT_AVATAR);
    }

    @Override
    public int getOrder() {
        return Ordered.LOWEST_PRECEDENCE;
    }
}
